package excutors;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ThreadPoolTest {
    public static void main(String[] args) {
        CustomRejectedExecutionHandler customRejectedExecutionHandler = new CustomRejectedExecutionHandler();
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1,
                1, 10,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(1)
                , customRejectedExecutionHandler);
        for (int i = 0; i < 100; i++) {
            threadPoolExecutor.execute(() ->
                    System.out.println(Thread.currentThread().getName()
                            + " is running"));
        }

    }
}
